8378908: [lworld] Serializations warnings for value classes that have private serialization methods#2187
Conversation
… private serialization methods
| case "readObject" -> checkReadObject(tree,e, method); | ||
| case "readObjectNoData" -> checkReadObjectNoData(tree, e, method); | ||
| case "readResolve" -> checkReadResolve(tree, e, method); | ||
| case "writeObject" -> isSerialMethodCorrect[0] = hasAppropriateWriteObject(tree, e, method); |
There was a problem hiding this comment.
some changes in this method and in the methods invoked here were not strictly necessary but were done for the sake of uniformity
There was a problem hiding this comment.
Can we convert this to a switch expression, like:
isSerialMethodCorrect[0] = switch (name) {
case "writeObject" -> hasAppropriateWriteObject(tree, e, method);and so on.
|
👋 Welcome back vromero! A progress list of the required criteria for merging this PR into |
|
❗ This change is not yet ready to be integrated. |
Webrevs
|
| case "readObject" -> checkReadObject(tree,e, method); | ||
| case "readObjectNoData" -> checkReadObjectNoData(tree, e, method); | ||
| case "readResolve" -> checkReadResolve(tree, e, method); | ||
| case "writeObject" -> isSerialMethodCorrect[0] = hasAppropriateWriteObject(tree, e, method); |
There was a problem hiding this comment.
Can we convert this to a switch expression, like:
isSerialMethodCorrect[0] = switch (name) {
case "writeObject" -> hasAppropriateWriteObject(tree, e, method);and so on.
src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java
Outdated
Show resolved
Hide resolved
src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java
Outdated
Show resolved
Hide resolved
…java Co-authored-by: Chen Liang <liach@openjdk.org>
…java Co-authored-by: Chen Liang <liach@openjdk.org>
| * @throws InvalidObjectException always | ||
| */ | ||
| @java.io.Serial | ||
| @SuppressWarnings("serial") |
There was a problem hiding this comment.
The other uses of @SuppressSerial in the JDK tend to have a comment explaining why the warning is being suppressed.
| // fields | ||
| final boolean[] hasWriteReplace = {false}; | ||
| final Map<String, Symbol> declaredSerialMethodNames = new HashMap<>(); | ||
| final boolean[] isSerialMethodCorrect = new boolean[] { false }; |
There was a problem hiding this comment.
Why is a one-element boolean array being used as opposed to a (non-final) boolean?
There was a problem hiding this comment.
Because this is passed to a lambda expression, which requires final local variables.
| LintWarnings.SerializableValueClassWithoutWriteReplace2); | ||
| } | ||
| } | ||
| if (c.isValueClass()) { |
There was a problem hiding this comment.
I think a short comment here explaining the rules for serializable value classes would be helpful.
|
|
||
| // Check for missing serialVersionUID; check *not* done | ||
| // for enums or records. | ||
| VarSymbol svuidSym = null; |
There was a problem hiding this comment.
Do value classes need any distinct serialVersionUID handling?
There was a problem hiding this comment.
not sure I get your question. Why should they?
There was a problem hiding this comment.
Hi @RogerRiggs, thanks for making a comment in an OpenJDK project!
All comments and discussions in the OpenJDK Community must be made available under the OpenJDK Terms of Use. If you already are an OpenJDK Author, Committer or Reviewer, please click here to open a new issue so that we can record that fact. Please Use "Add GitHub user RogerRiggs" for the summary.
If you are not an OpenJDK Author, Committer or Reviewer, simply check the box below to accept the OpenJDK Terms of Use for your comments.
- I agree to the OpenJDK Terms of Use for all comments I make in a project in the OpenJDK GitHub organization.
Your comment will be automatically restored once you have accepted the OpenJDK Terms of Use.
There was a problem hiding this comment.
not sure I get your question. Why should they?
I don't know if they do; that's why I was asking :-)
I think my concerns would be addressed by a "here's how serial value classes work."
There was a problem hiding this comment.
Oh I see, thanks @RogerRiggs for your answer. I didn't know that specific about migrated value classes. I will add a comment
There was a problem hiding this comment.
Hi @RogerRiggs, thanks for making a comment in an OpenJDK project!
All comments and discussions in the OpenJDK Community must be made available under the OpenJDK Terms of Use. If you already are an OpenJDK Author, Committer or Reviewer, please click here to open a new issue so that we can record that fact. Please Use "Add GitHub user RogerRiggs" for the summary.
If you are not an OpenJDK Author, Committer or Reviewer, simply check the box below to accept the OpenJDK Terms of Use for your comments.
- I agree to the OpenJDK Terms of Use for all comments I make in a project in the OpenJDK GitHub organization.
Your comment will be automatically restored once you have accepted the OpenJDK Terms of Use.
|
@vicente-romero-oracle, updates generally looks good; I can given a final re-review after JavaOne. |
This PR is adding a new serialization warning for the case when a value class declares one of the following serialization related methods:
They have no effect if declared in value classes, fact that should be notified to the user,
TIA
Progress
Issue
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/valhalla.git pull/2187/head:pull/2187$ git checkout pull/2187Update a local copy of the PR:
$ git checkout pull/2187$ git pull https://git.openjdk.org/valhalla.git pull/2187/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 2187View PR using the GUI difftool:
$ git pr show -t 2187Using diff file
Download this PR as a diff file:
https://git.openjdk.org/valhalla/pull/2187.diff
Using Webrev
Link to Webrev Comment